package cn.jksoft.businessclient.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.jksoft.businessclient.R;
import cn.jksoft.businessclient.bean.AreaEntity;

/**
 * Author:  nick
 * Email:   nickdevp@gmail.com
 * Date:    16/4/7 18:10.
 * Description:
 */
public class PopupAdapter extends RecyclerView.Adapter<PopupAdapter.ItemViewHolder> {
    private Context context;
    private LayoutInflater inflater;
    private List<AreaEntity.DataEntity> dataList;

    public PopupAdapter(Context context,List<AreaEntity.DataEntity> list) {
        this.context = context;
        this.dataList = list;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public ItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View view = inflater.inflate(R.layout.popup_list_item, viewGroup, false);
        ItemViewHolder itemViewHolder = new ItemViewHolder(view);
        return itemViewHolder;
    }

    @Override
    public void onBindViewHolder(final ItemViewHolder itemViewHolder, int position) {

        itemViewHolder.tvText.setText(dataList.get(position).getCarPlateGeoName());

    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }

    public static class ItemViewHolder extends RecyclerView.ViewHolder {

        @Bind(R.id.tv_text)
        TextView tvText;

        public ItemViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
